const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');

const User = sequelize.define('User', {
  id: { type: DataTypes.INTEGER.UNSIGNED, primaryKey: true, autoIncrement: true },
  nick_name: { type: DataTypes.STRING(50), allowNull: false, field: 'nick_name' },
  avatar_url: { type: DataTypes.STRING(255), allowNull: true, field: 'avatar_url' },
  openid: { type: DataTypes.STRING(128), allowNull: true, unique: true, field: 'openid' },
  is_active: { type: DataTypes.TINYINT, allowNull: false, defaultValue: 1, field: 'is_active' }
}, {
  tableName: 'users',
  timestamps: true,
  createdAt: 'created_at',
  updatedAt: 'updated_at'
});

module.exports = User;